home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / Speech Synthesis Manager / Installer Source / ActionAtoms / ResolveAliasAA.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-11  |  2.0 KB  |  82 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *    File:        ResolveAliasAA.c -    C Source
  4.  *
  5.  *    Author:        Deric Horn
  6.  *
  7.  *    Action Atom to resolve alias files of specified infs file
  8.  *
  9.  *    History:    <1>    (12/2/94) Created this file.
  10.  *
  11.  *----------------------------------------------------------------------------*/
  12.  
  13. #include    <Resources.h>
  14. #include    <Aliases.h>
  15. #include    "AtomUtils.h"
  16.  
  17.  
  18. //        Function Prototypes
  19. pascal long    RESOLVEALIAS(AAPBRecPtr myAAPBPtr);
  20. OSErr myResolveAlias (AAPBRecPtr myAAPBPtr);
  21.  
  22.  
  23. pascal long    RESOLVEALIAS(AAPBRecPtr myAAPBPtr)
  24. {
  25.     OSErr        err        =    noErr;
  26.  
  27.     if (myAAPBPtr->whichStage == after)        // make sure that this is the right stage
  28.     {                                        // and that the atom is not being called
  29.                                             // as a result of a cancel operation
  30.         err = myResolveAlias( myAAPBPtr );
  31.         return ( err );
  32.     }
  33.     return( 1 );
  34. }
  35.  
  36. OSErr myResolveAlias (AAPBRecPtr myAAPBPtr)
  37. {
  38.     infsHdl            myinfsH;
  39.     infsPtr            myinfs;
  40.     Handle            theAlias;
  41.     FSSpec            from,to;
  42.     short             myResFile;
  43.     short             aResFileRefNum;
  44.     unsigned char    changed;
  45.     OSErr            err = noErr;
  46.  
  47.     myinfsH=(infsHdl)Get1Resource('infs',myAAPBPtr->aaRefCon);
  48.     if (myinfsH!=0)
  49.     {
  50.         HLock((Handle)myinfsH);                                        // lock and dereference
  51.         myinfs=*myinfsH;
  52.  
  53.         if ( MakeFSSpecFromAAPB( &from, myinfs->pathName, myAAPBPtr ) == noErr )
  54.         {
  55.             myResFile=CurResFile();                                    // store current resfile
  56.             aResFileRefNum=FSpOpenResFile(&from, fsWrPerm);            // open the rsrcfork 
  57.  
  58.             theAlias=Get1Resource('alis',0);
  59.             if (theAlias!=0)
  60.             {
  61.                 if (ResolveAlias(&from,(AliasHandle)theAlias,&to,&changed)==noErr)
  62.                 {
  63.                     if (changed)
  64.                     {
  65.                         ChangedResource(theAlias);
  66.                         UpdateResFile(aResFileRefNum);
  67.                         err = noErr;
  68.                     }
  69.                 }
  70.                 else err = 1;
  71.             }
  72.             CloseResFile(aResFileRefNum);                            // close the damn thing
  73.             UseResFile(myResFile);                                    // restore current resfile
  74.  
  75.             if (err==1)
  76.                 FSpDelete(&from);                            // if we could not resolve the alias delete it.
  77.         }
  78.         HUnlock((Handle)myinfsH);
  79.     }
  80.     return(noErr);
  81. }
  82.